package cn.loioi.multi.mysql.been;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;

import cn.loioi.multi.mysql.model.SysRole;
import tk.mybatis.mapper.common.Mapper;

public interface SysRoleMapper extends Mapper<SysRole> {

	@ResultType(String.class)
	@Select("SELECT DISTINCT sys_role.identity FROM sys_user_role INNER JOIN sys_role ON sys_user_role.role = sys_role.id WHERE sys_user_role.account = #{account}")
	List<String> roles(@Param("account") String account);

	@ResultMap("BaseResultMap")
	@Select("SELECT sys_role.id, sys_role.`name`, sys_role.identity, sys_role.create_time, sys_role.update_time, sys_role.delete_time FROM sys_role INNER JOIN sys_user_role ON sys_user_role.role = sys_role.id WHERE sys_user_role.account = #{account}")
	List<SysRole> getRoles(@Param("account") String account);
}